window.tools= {};
window.tools.getMouse = function(element){
	var mouse = {x:0 , y:0};
	element.addEventListener("mousemove",function(e){
		var x,y;
		var e = e || window.event;
		if(e.pageX||e.pageY){
			x=e.pageX;
			y=e.pageY;
		}
		else{
			x=e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			y=e.clienty + document.body.scrollTop + document.documentElement.scrollTop;
		}
		x -=element.offsetLeft;
		y -=element.offsetTop;
		
		mouse.x=x;
		mouse.y=y;
	})
	return mouse;
}
window.tools.getKey = function(){
	var key = {};
	window.addEventListener("keydown",function(e){
		if(e.keyCode ==38 ||e.keyCode ==87){
			key.direction ="up";
		}else if(e.keyCode ==39 ||e.keyCode ==68){
			key.direction ="right";
		}else if(e.keyCode ==40 ||e.keyCode ==83){
			key.direction ="down";
		}else if(e.keyCode ==37 ||e.keyCode ==65){
			key.direction ="left";
		}else{
			key.direction ="";
		}
	},false);
	return key;
}
window.requestAnimationFrame =(
	window.webkitRequestAnimationFrame ||
	window.mozAnimationStartTime||
	window.msRequestAnimationFrame()||
	window.oRequestAnimationFrame()||
	function(callback){
		return window.setTimeout(callback,1000/60);
	}
);
